const api = {
    userLogin(mobile_phone, callback) { //登陆
        return uni.request({
            url: "http://caco.winhui.net/api/v1/users/userLogin",
            data: {
                mobile_phone: mobile_phone
            },
            success: function (res) {
                callback(res)
            }
        })
    },
    getAllShop(user_id, page = 0, size = 10, callback) { //查询所有店铺
        return uni.request({
            url: "http://caco.winhui.net/api/v1/shop/getAllShop",
            data: {
                user_id: user_id,
                page: page,
                size: size
            },
            success: function (res) {
                callback(res)
            }
        })
    },
    updateDate(code=10001, type ,callback) { //数据是否有更新
        return uni.request({
            url: "http://caco.winhui.net/api/v1/order/updateDate",
            data: {
                code: code,
                type: type
            },
            success: function (res) {
                callback(res)
            }
        })
    },
    getQuesionts(unit,page,size,callback) { //查询所有问卷
        return uni.request({
            url: "http://caco.winhui.net/api/v1/order/getQuesionts",
            data: {
                unit: unit,
                page: page,
                size: size
            },
            success: function (res) {
                callback(res)
            }
        })
    },
    setQuesionts(data1, callback) { //提交问卷
        let dataString = JSON.stringify(data1);
        console.log(dataString)
        return uni.request({
            url: "http://caco.winhui.net/api/v1/order/setQuesionts",
            header:{'content-type':'application/x-www-form-urlencoded'},
            method:"POST",
            dataType:'json',
            data:{
               data1: dataString
            },
            success: function (res) {
                callback(res)
            }
        })
    },
    imgUpload(filePath, callback) { //上传图片（允许多个一起上传）
        return uni.uploadFile({
            url: "http://caco.winhui.net/api/v1/upload/imgUpload",
            fileType:'image',
            filePath: filePath,
            name: 'file',
            success: function (res) {
                callback(res)
            }
        })
    },
}

module.exports = api